package seeders

import (
	"github.com/goravel/framework/facades"
	"goravel/app/models"
)

type ReadcmdSeeder struct {
}

// Signature The name and signature of the seeder.
func (s *ReadcmdSeeder) Signature() string {
	return "ReadcmdSeeder"
}

// Run executes the seeder logic.
func (s *ReadcmdSeeder) Run() error {
	var readcmds = []models.Readcmd{
		models.Readcmd{
			DataAddress: "0x1000",
			ByteSize:    2,
			Parameter:   "总电流",
			Unit:        "0.1A",
			Note:        "充电+，放电-",
		},
		models.Readcmd{
			DataAddress: "0x1001",
			ByteSize:    2,
			Parameter:   "电流绝对值",
			Unit:        "0.1A",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1002",
			ByteSize:    2,
			Parameter:   "电池端电压",
			Unit:        "0.1V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1003",
			ByteSize:    2,
			Parameter:   "Pack端电压",
			Unit:        "0.1V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1004",
			ByteSize:    2,
			Parameter:   "SOC实际值",
			Unit:        "0.01%",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1005",
			ByteSize:    2,
			Parameter:   "SOC显示值",
			Unit:        "0.01%",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1007",
			ByteSize:    4,
			Parameter:   "工作模式",
			Unit:        "",
			Note:        `"0：上电1：准备2：预充3：放电4：充电5：错误6：警告7：诊断8：待机9：关机"`,
		},
		models.Readcmd{
			DataAddress: "0x1009",
			ByteSize:    4,
			Parameter:   "预充继电器状态",
			Unit:        "",
			Note:        `"0：初始化1：预充2：预放3：正常4：开启5：闭合"`,
		},
		models.Readcmd{
			DataAddress: "0x100A",
			ByteSize:    2,
			Parameter:   "AFE基准电压",
			Unit:        "0.001V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x100B",
			ByteSize:    2,
			Parameter:   "正极绝缘阻值",
			Unit:        "1kΩ",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x100C",
			ByteSize:    2,
			Parameter:   "负极绝缘阻值",
			Unit:        "1kΩ",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x100D",
			ByteSize:    2,
			Parameter:   "模组电压和",
			Unit:        "0.1V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x100E",
			ByteSize:    2,
			Parameter:   "单体最高电压",
			Unit:        "0.001V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x100F",
			ByteSize:    2,
			Parameter:   "单体最低电压",
			Unit:        "0.001V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1010",
			ByteSize:    2,
			Parameter:   "平均电压",
			Unit:        "0.001V",
			Note:        "",
		},
		models.Readcmd{
			DataAddress: "0x1011-0x1030",
			ByteSize:    2,
			Parameter:   "单体电压N",
			Unit:        "0.001V",
			Note:        "N=1,2,3…32",
		},
		models.Readcmd{
			DataAddress: "0x1031-0x1036",
			ByteSize:    1,
			Parameter:   "单体温度N",
			Unit:        "1℃",
			Note:        "N=1,2,3…12偏移量-40℃",
		},
		models.Readcmd{
			DataAddress: "0x1031-0x1036",
			ByteSize:    1,
			Parameter:   "单体温度N",
			Unit:        "1℃",
			Note:        "N=1,2,3…12偏移量-40℃",
		},
	}
	facades.Orm().Query().Model(&models.Readcmd{}).Create(readcmds)
	return nil
}
